﻿// LightNet - Lightweight .NET Framework
// Copyright (c) 2010 http://lightnet.codeplex.com

namespace System
{
    using System.Security;

    /// <summary>
    /// The exception that is thrown when type-loading failures occur.
    /// </summary>
    public class TypeLoadException : SystemException
    {
        private string AssemblyName;
        private string ClassName;
        private string MessageArg;
        internal int ResourceId;

        public override string Message
        {
            [SecuritySafeCritical]
            get
            {
                return base.Message;
            }
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="T:System.TypeLoadException" /> class.
        /// </summary>
        public TypeLoadException()
            : base()
        {
            base.SetErrorCode(-2146233054);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="T:System.TypeLoadException" /> class with a specified error message.
        /// </summary>
        /// <param name="message">The message that describes the error.</param>
        public TypeLoadException(string message)
            : base(message)
        {
            base.SetErrorCode(-2146233054);
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="T:System.TypeLoadException" /> class with a specified error message and a reference to the inner exception that is the cause of this exception.
        /// </summary>
        /// <param name="message">The error message that explains the reason for the exception.</param>
        /// <param name="inner">The exception that is the cause of the current exception. If the <paramref name="inner" /> parameter is not null, the current exception is raised in a catch block that handles the inner exception.</param>
        public TypeLoadException(string message, Exception inner)
            : base(message, inner)
        {
            base.SetErrorCode(-2146233054);
        }

        [SecurityCritical]
        private TypeLoadException(string className, string assemblyName, string messageArg, int resourceId)
            : base(null)
        {
            base.SetErrorCode(-2146233054);
            ClassName = className;
            AssemblyName = assemblyName;
            MessageArg = messageArg;
            ResourceId = resourceId;
        }
    }
}
